package com.lovo.service.impl;

import com.lovo.dao.UserDAO;
import com.lovo.model.UserDO;
import com.lovo.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Resource
    private UserDAO userDAO;
    @Override
    public List findAll() {
        return userDAO.findAll();
    }

    @Override
    public void save(UserDO userDO) {
        userDAO.save(userDO);
    }

    @Override
    public void update(UserDO userDO) {
        userDAO.save(userDO);
    }

    @Override
    public UserDO validate(String name, String pwd) {
        return userDAO.findByNameAndPwd(name,pwd);
    }

    @Override
    public List find(String name) {
        return userDAO.findCondition(name);
    }

    @Override
    public UserDO findById(Integer userId) {
        return userDAO.findById(userId).get();
    }

    @Override
    public void deleteByName(String name) {
        userDAO.deleteByName(name);
    }


}
